/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import Entity.JenisInstansi;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import library.Koneksi;

/**
 *
 * @author user
 */
public class DaftarJenisInstansi {
    
    JenisInstansi jenisInstansi;
    
    public List<JenisInstansi> ambilDaftarJenisInstansi(){
        List<JenisInstansi> daftarJenisInstansi = new ArrayList<JenisInstansi>();
        Koneksi dbConn = new Koneksi();
        String sql = "SELECT * FROM jenis_instansi_kerjasama";
        PreparedStatement st;
        try {

            Connection conn = Koneksi.getKoneksi();

            st = conn.prepareStatement(sql);
            ResultSet rs = st.executeQuery();

            while(rs.next()){
                this.jenisInstansi = new JenisInstansi();
                jenisInstansi.setIdJenisInstansi(rs.getInt("ID_JENIS_INSTANSI"));
                jenisInstansi.setJenisInstansi(rs.getString("JENIS_INSTANSI"));
                daftarJenisInstansi.add(jenisInstansi);
            }
        } catch (SQLException ex) {
            Logger.getLogger(DaftarJenisInstansi.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            dbConn.closeConnection();
        }
        return daftarJenisInstansi;
    }
    
}
